<?php

namespace App\Expansion;

use Swoft\Bean\Annotation\Mapping\Bean;
use Swoft\Bean\Annotation\Mapping\Inject;
use Swoft\Consul\Consul;
use Swoft\Consul\Exception\ClientException;
use Swoft\Consul\Exception\ServerException;
use Swoft\Consul\Response;
use Swoft\Consul\Agent as base;

/**
 * Agent
 * @Bean()
 */
class Agent extends base
{
    /**
     * @Inject()
     *
     * @var Consul
     */
    private $consul;

    /**
     * @param string $serverName
     * @return Response
     * @throws ClientException
     * @throws ServerException
     */
    public function getServices(string $serverName): Response
    {
        return $this->consul->get('/v1/health/service/' . $serverName);
    }
}